package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.ctrl.domain.EqptCptestStation;
import com.deyuanyun.pic.ctrl.domain.ExinspBuriedDepth;
import com.deyuanyun.pic.ctrl.enumeration.EvaluationLayingConditionEnum;
import com.deyuanyun.pic.ctrl.service.EQPTBaseService;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * 3管道埋深测试记录表
 */
public class ExinspBuriedDepthVO extends ExinspBaseVO<ExinspBuriedDepth> {

    // 管道名称
    private String pipeLineName;
    // 测试桩编号
    private String testStationNum;
    // 监测点编号（一个顺序数字而已）
    private String detectionPointNumber;
    // 绝对距离（m）
    private BigDecimal mileage;
    // 附近(最近)测试桩
    private String nagm;
    // 附近(最近)测试桩距离
    private BigDecimal nagmMileage;
    // 埋深（m）
    private BigDecimal buriedDepth;
    // 敷设状况评价（合格、埋深不足）
    private String evaluationOfLayingCondition;
    // 修复措施
    private String repairMeasures;
    // 检测日期
    private String testingDate;
    // 检测单位
    private String testingCompany;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getTestStationNum() {
        return testStationNum;
    }

    public void setTestStationNum(String testStationNum) {
        this.testStationNum = testStationNum;
    }

    public String getDetectionPointNumber() {
        return detectionPointNumber;
    }

    public void setDetectionPointNumber(String detectionPointNumber) {
        this.detectionPointNumber = detectionPointNumber;
    }

    public BigDecimal getMileage() {
        return mileage;
    }

    public void setMileage(BigDecimal mileage) {
        this.mileage = mileage;
    }

    public String getNagm() {
        return nagm;
    }

    public void setNagm(String nagm) {
        this.nagm = nagm;
    }

    public BigDecimal getNagmMileage() {
        return nagmMileage;
    }

    public void setNagmMileage(BigDecimal nagmMileage) {
        this.nagmMileage = nagmMileage;
    }

    public BigDecimal getBuriedDepth() {
        return buriedDepth;
    }

    public void setBuriedDepth(BigDecimal buriedDepth) {
        this.buriedDepth = buriedDepth;
    }

    public String getEvaluationOfLayingCondition() {
        return evaluationOfLayingCondition;
    }

    public void setEvaluationOfLayingCondition(String evaluationOfLayingCondition) {
        this.evaluationOfLayingCondition = evaluationOfLayingCondition;
    }

    public String getRepairMeasures() {
        return repairMeasures;
    }

    public void setRepairMeasures(String repairMeasures) {
        this.repairMeasures = repairMeasures;
    }

    public String getTestingDate() {
        return testingDate;
    }

    public void setTestingDate(String testingDate) {
        this.testingDate = testingDate;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    EQPTBaseService eqptBaseService = SpringAppliction.getBean(EQPTBaseService.class);

    public void fromDomain(ExinspBuriedDepth domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 测试桩编号
        EqptCptestStation testEqptCptestStation = eqptBaseService.queryObjectByPrimaryKey(EqptCptestStation.class, domain.getTestStationId());
        this.testStationNum = testEqptCptestStation==null ? null : testEqptCptestStation.getCustomNumber();
        // 监测点编号（一个顺序数字而已）
        this.detectionPointNumber = domain.getDetectionPointNumber();
        // 绝对距离（m）
        this.mileage = NumberUtil.toMeter(domain.getMileage());
        // 附近(最近)测试桩
        EqptCptestStation eqptCptestStation = eqptBaseService.queryObjectByPrimaryKey(EqptCptestStation.class, domain.getNagm());
        this.nagm = eqptCptestStation==null ? null : eqptCptestStation.getCustomNumber();
        // 附近(最近)测试桩距离
        this.nagmMileage = NumberUtil.toMeter(domain.getNagmMileage());
        // 埋深（m）
        this.buriedDepth = domain.getBuriedDepth();
        // 敷设状况评价（合格、埋深不足）
        this.evaluationOfLayingCondition = EvaluationLayingConditionEnum.getLabel(domain.getEvaluationOfLayingCondition());
        // 修复措施
        this.repairMeasures = domain.getRepairMeasures();
        // 检测日期
        this.testingDate = DateFormat.format(domain.getTestingDate());
        // 检测单位
        this.testingCompany = domain.getTestingCompany();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<ExinspBuriedDepthVO> fromDomainList(Page<ExinspBuriedDepth> domainList) {

        Page<ExinspBuriedDepthVO> list = new Page<ExinspBuriedDepthVO>();
        for (ExinspBuriedDepth exinspBuriedDepth : domainList) {
            ExinspBuriedDepthVO exinspBuriedDepthVO = new ExinspBuriedDepthVO();
            exinspBuriedDepthVO.fromDomain(exinspBuriedDepth);
            list.add(exinspBuriedDepthVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}